package rottenTomatoes;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


/**
 * This is simple example of JTomato
 * 
 * @author <a href="mailto:tambug@gmail.com">Giordano Tamburrelli</a>
 * 
 * @version 1.0
 **/

public class Example {

	private static Scanner sc;

	public static void main(String[] args) {
		
		sc = new Scanner(System.in);
		
		String filme = sc.next();
		
		// Creating a JTomato instance, you need a valid API key.
		JTomato jtomato = new JTomato("qfewgdfqxwtvxe9g5xc6efu2");
		
		//setting the number of results per page. Default is 30.
		jtomato.setPage_limit(10);

		// Creating a list to store the result
		List<Movie> movies = new ArrayList<Movie>();

		// Searching a movie, page 1
		int total = jtomato.searchMovie(filme, movies, 1);
		System.out.println("Foram encontrados " + total + " resultados");
		System.out.println("Primeiro resultado: " + movies.get(0));
		
		// Obtaining additional info
		Movie movie = jtomato.getMovieAdditionalInfo(movies.get(0));
		// Printing the movie genre
		System.out.println("Genero do filme: "+ movie.genres.get(0));
		System.out.println("Ano do filme: " + movie.year);
		System.out.println("Sinopse: " + movie.synopsis);
		System.out.println("Tempo de filme: " + movie.runtime + " minutos");
		System.out.println("Gêneros: " + movie.genres);		
		System.out.println(movie.posters.profile);
		// Getting similar movies
		List<Movie> similarMovies = jtomato.getSimilarMovies(movie, "us", 5);
		System.out.println("Um filme similar: " + similarMovies.get(0));
	}	
}